package com.fmy.jurisdiction.modular.wrapper.obj;

import com.fmy.jurisdiction.core.commons.factory.ConstantFactory;
import com.fmy.jurisdiction.modular.model.AdminUser;
import com.fmy.jurisdiction.modular.wrapper.ObjectWrapper;

import java.util.Map;

/**
 * @author Mr.fmy
 * @version 1.0.0
 * @ClassName AdminUserWrapper
 * @Description TODO 管理员用户 包装类
 * @createTime 2019/9/16 15:29
 */
public class AdminUserWrapper extends ObjectWrapper {

    public AdminUserWrapper(Object obj) {
        super(obj);
    }

    @Override
    protected void wrp(Object t) {
        if (t instanceof Map) {
            Map<String, Object> map = (Map<String, Object>) t;
            map.put(AdminUser.ROLES_FIELD, ConstantFactory.me().getRoleNames((String) map.get(AdminUser.ROLES_FIELD)));
            map.put(AdminUser.CREATE_USER_FIELD, ConstantFactory.me().getUserName((Integer) map.get(AdminUser.CREATE_USER_FIELD)));
            map.put(AdminUser.MODIFY_USER_FIELD, ConstantFactory.me().getUserName((Integer) map.get(AdminUser.MODIFY_USER_FIELD)));
            map.put(AdminUser.DEPT_ID_FIELD, ConstantFactory.me().getDeptName((Integer) map.get(AdminUser.DEPT_ID_FIELD)));
        }
    }
}
